#include<stdio.h>
using namespace std;
int ma[10][10],step[10][10]={0},vis[10][10]={0},dx[4]={1,0,0,-1},dy[8]={0,-1,1,0};
bool out_of_ma(int x,int y){
	if(x>0&&x<=5&&y>0&&y<=5) return 0;
	return 1;
}
void find(int x,int y){
	if(out_of_ma(x,y)) return;
	for(int i=0;i<4;i++){
		if(!ma[x+dx[i]][y+dy[i]]&&((step[x+dx[i]][y+dy[i]]>=step[x][y])||step[x+dx[i]][y+dy[i]]==0)&&!vis[x+dx[i]][y+dy[i]]){
			step[x+dx[i]][y+dy[i]]=step[x][y]+1;
			vis[x+dx[i]][y+dy[i]]=1;
			find(x+dx[i],y+dy[i]);
			vis[x+dx[i]][y+dy[i]]=0;
		}
	}
}
void the_road(int x,int y){
	if(out_of_ma(x,y)) return;
	for(int i=0;i<4;i++){
		if(step[x+dx[i]][y+dy[i]]==step[x][y]-1&&!ma[x+dx[i]][y+dy[i]]){
			vis[x+dx[i]][y+dy[i]]=1;
			the_road(x+dx[i],y+dy[i]);			
		}
	}	
}
void give_road(int x,int y){
	if(out_of_ma(x,y)||!vis[x][y]) return;
	if(vis[x][y]){
		printf("(%d, %d)\n",x-1,y-1);
		vis[x][y]=0;
	}
	for(int i=0;i<4;i++){
		if(vis[x+dx[i]][y+dy[i]]){
			give_road(x+dx[i],y+dy[i]);
		}
	}
}
int main(){
	for(int i=1;i<=5;i++){
		for(int j=1;j<=5;j++){
			scanf("%d",&ma[i][j]);
		}
	}
	step[1][1]=1;
	vis[1][1]=1;
	find(1,1);
	vis[5][5]=1;
	the_road(5,5);
	give_road(1,1);
}
